define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {


    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'information/actionlog/index' + location.search,
                    del_url: 'information/actionlog/del',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                singleSelect:false,
                fixedColumns: true,
                fixedRightNumber: 1,
                showExport: false,
                showToggle:false,
                //showFullscreen:true,
                //striped:true,
                //remember: true,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title:__('Id'), operate: false},
                        {field: 'type', title: __('Type'), searchList: {"1":__('Type 1')," 2":__('Type  2')}, formatter: Table.api.formatter.normal},
                        {field: 'username', title: __('Username'), operate: 'LIKE'},
                        {field: 'action', title: __('Action'), operate: 'LIKE',width:100},
                        {field: 'url', title: __('Url'), operate: 'LIKE'},
                        {field: 'result', title: __('Result'), operate: 'LIKE',width:300},
                        {field: 'create_date', title: __('Create_date'),width:120, operate:'RANGE', addclass:'datetimerange', autocomplete:false,width:120},
                        {field: 'uuid', title: __('Uuid'), operate: 'LIKE',width:150},
                        {
                            field: 'operate', title: __('Operate'), table: table,
                            events: Table.api.events.operate,
                            buttons: [{
                                name: 'detail',
                                text: __('Detail'),
                                icon: 'fa ',
                                classname: 'btn btn-info btn-xs btn-detail btn-dialog',
                                url: 'information/actionlog/detail'
                            }],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });
         // 为表格绑定事件
            Table.api.bindevent(table);
            
            $(table).data("operate-del", null);
        },

        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            //获取选中的行
            selectedids: function (table, current) {
                var options = table.bootstrapTable('getOptions');
                //如果有设置翻页记忆模式
                if (!current && options.maintainSelected) {
                    return options.selectedIds;
                }
                return $.map(table.bootstrapTable('getSelections'), function (row) {
                    return row[options.pk];
                });
            },

            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
